
namespace Core
{
    using System;
    using Contracts.Interfaces;

    /// <summary>
    /// Lazy loading feature class
    /// </summary>
    public sealed class LazyFeature
    {
        private readonly Lazy<IFeature<object>> _lazy;

        /// <summary>
        /// Creates a new instance
        /// </summary>
        /// <param name="featureType">The type of the feature</param>
        /// <param name="value">The value of the feature</param>
        public LazyFeature(Type featureType, object value) 
        {
            _lazy = new Lazy<IFeature<object>>(() => Activator.CreateInstance(featureType, value) as IFeature<object>);
        }
        /// <summary>
        /// Obtains the feature
        /// </summary>
        public IFeature<object> Feature
        {
            get { return _lazy.Value; }
        }
    }
}